package com.xinqi.modules.homework.homework.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xinqi.common.mybatis.data.repo.SuperMapper;
import com.xinqi.modules.homework.homework.domain.CourseHomeworkEntity;
import com.xinqi.modules.homework.homework.domain.CourseHomeworkStudentLogEntity;
import com.xinqi.modules.homework.homework.dto.req.CourseHomeworkStudentBaseDTO;
import com.xinqi.modules.homework.homework.dto.req.CourseHomeworkStudentDetailDTO;
import com.xinqi.modules.homework.homework.dto.req.CourseHomeworkStudentLogQueryDTO;
import com.xinqi.modules.homework.homework.dto.rsp.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * 数据层
 *
 * @author: system
 * @date: 2023/03/08
 */
@Mapper
public interface CourseHomeworkStudentLogMapper extends SuperMapper<CourseHomeworkStudentLogEntity> {

    IPage<CourseHomeworkStudentResultDTO> homeworkStudentList(Page<CourseHomeworkStudentResultDTO> page, @Param("query") CourseHomeworkStudentLogQueryDTO dto);

    /*学生作业各种状态多选查询*/
    List<CourseHomeworkStudentInfoResultDTO> homeworkStudentInfoList(@Param("dto") CourseHomeworkStudentLogQueryDTO dto);

    IPage<CourseHomeworkStudentInfoResultDTO> homeworkStudentPage(Page<CourseHomeworkStudentInfoResultDTO> page, @Param("dto") CourseHomeworkStudentLogQueryDTO dto);

    /*学生参与率查询查询*/
    List<CourseHomeworkStudentPartakeResultDTO> homeworkStudentPartakeList(CourseHomeworkStudentLogQueryDTO dto);

    /**
     * 根据状态查询列表
     */
    List<CourseHomeworkStudentInfoResultDTO> homeworkStudentInfoListByStatus(CourseHomeworkStudentBaseDTO dto);

    /**
     * 查询作业学生最大分数
     */
    BigDecimal homeworkMaxStudentScore(Long contentId);

    /**
     * 删除多余的轮数-学生打卡记录
     */
    boolean deleteByHomework(CourseHomeworkEntity entity);

    /**
     * 加入班级初始化进行中的作业
     */
    List<CourseHomeworkEntity> findRunningHomework(CourseHomeworkStudentLogEntity entity);

    /**
     * 加入班级初始化进行中的作业
     */
    List<CourseHomeworkStudentLogEntity> findStudentRunningHomework(CourseHomeworkStudentLogEntity entity);

    /**
     * 退出班级移除进行中的作业
     */
    boolean deleteRunningStudentHomework(CourseHomeworkStudentLogEntity entity);

    long homeworkStudentTotal(@Param("dto") CourseHomeworkStudentLogQueryDTO dto);


    List<CourseHomeworkStudentLogResultDTO> studentRepeatList(@Param("query") CourseHomeworkStudentDetailDTO dto);

    CourseHomeworkStudentLogResultDTO studentRepeatNext(@Param("query") CourseHomeworkStudentDetailDTO dto);

    /**
     * 获取作业提交情况
     */
    CourseHomeworkTimerResultDTO findSubmitStatus(@Param("contentId") Long contentId);
}
